<?php
/* ******************************
	Incoming Tasks aJax actions
   ******************************
*/
	include('../../includes/classes/core.php');
	$action = $_REQUEST['act'];
	
	switch ($action) {
	    case 'get_list':
    	    $count = $_REQUEST['count'];
    	    
    	    $rResult = mysql_query("
    	    						SELECT 		`order`.id,
												'შეკვეთა' as a,
												`order`.date,
												'' as b,
												`persons`.`name` AS c,
												`order`.`number`,
												'' AS d,
												'' AS e
									FROM 		`order` LEFT JOIN persons
									ON   		`order`.`person` = `persons`.`id`
									WHERE 		`status` = '0'
    	    		
    	    						UNION				
    	    		
    	    						SELECT 	
    	    									`overhead`.`id`,
    	    									`overhead_types`.`name`,
												`overhead`.`create_date`,
												`overhead`.`seller_tin`,
												`overhead`.`seller_name`,
												`overhead`.`waybill_number`,
												`overhead`.`full_amount`,
    	    		                        	'' AS  	 des
									
									FROM 		`overhead`
									LEFT JOIN 	`overhead_types`
									ON 			`overhead`.`type` = `overhead_types`.`id`
									WHERE 		`overhead`.`is_confirmed` = 0
                                    ");
			
			$output = array(
				"aaData"	=> array()
			);
			
			while ( $aRow = mysql_fetch_array( $rResult ) )
			{
				$row = array();
				for ( $i = 0 ; $i < $count ; $i++ )
				{
					/* General output */
					$row[] = $aRow[$i];
				}
				$output['aaData'][] = $row;
			}
			
			echo json_encode( $output );

	        break;	    
	    default:
	       echo "null";
	}
?>